package org.moflon.boardgamegui.view.menubar.actions;

import org.apache.log4j.BasicConfigurator;
import org.eclipse.jface.action.Action;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.moflon.boardgamegui.view.View;


public class SaveAction extends Action 
{	
	View view;

	public SaveAction(View view)
	{
		this.view = view;
		setText("Save");
		setToolTipText("Save current board");		
	}

	public void run()
	{
		BasicConfigurator.configure();
		FileDialog fileDialog = new FileDialog(view.getShell(),SWT.SAVE);
		fileDialog.setFileName("instances/");
		String[] extensions = {"*.xmi"};
		fileDialog.setFilterExtensions(extensions);
		String filePath = fileDialog.open(); 	
		    
		// Save model to file
		if(filePath != null)
			view.getController().saveModel(filePath);	
	}

}
